<!DOCTYPE html>
<html lang="en" class="bg-white" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>合同录入</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{../assets/libs/layui/css/layui.css}"/>
    <link rel="stylesheet" href="../../assets/module/admin.css?v=311"/>
    <style>
        .layui-form-item {
            margin-bottom: 0;
            margin-top: 20px;
        }

        .layui-form-item .layui-inline {
            margin-bottom: 25px;
            margin-right: 0;
        }
    </style>
</head>

<body>

<!-- 加载动画，移除位置在common.js中 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">合同基本信息</li>
            <li>合同照上传</li>
        </ul>
        <div class="layui-tab-content" style="height: 100px;">
            <div class="layui-tab-item layui-show">
                <div class="layui-card">
                    <div class="layui-card-header">客户信息</div>
                    <div class="layui-card-body">
                        <form class="layui-form layui-form-pane">
                            <div class="layui-form-item layui-row">
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">姓 名:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_name" type="text" placeholder="请输入加盟商姓名" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">联系电话:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_phone" type="text" placeholder="请输入联系电话" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">性别:</label>
                                    <div class="layui-input-block">
                                        <select name="sys_cs_sex">
                                            <option value="">请选择性别</option>
                                            <option value="0">男</option>
                                            <option value="1">女</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">个人邮箱:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_email" type="text" placeholder="请输入联系邮箱" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">所属公司:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_company" type="text" placeholder="请输入公司名称" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">执照编号:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_zipcode" type="text" placeholder="请输入加盟商执照编号" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">身份证号:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_idcard" type="text" placeholder="请输入加盟商身份证号" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">详细地址:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_address" type="text" placeholder="请输入加盟商详细地址" class="layui-input"/>
                                    </div>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
                <div class="layui-card">
                    <div class="layui-card-header">合同信息</div>
                    <div class="layui-card-body">
                        <form class="layui-form layui-form-pane" lay-filter="test1">
                            <div class="layui-form-item layui-row">
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">合同编号:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_id" type="text" placeholder="请输入合同编号" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">合同类型:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_type" type="text" placeholder="请输入合同类型" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">项目类型:</label>
                                    <div class="layui-input-block">
                                        <select id="sys_cs_project">
                                            <option value="0">请选择项目</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">加盟区域:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_region" type="text" placeholder="请输入加盟区域" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md8">
                                    <label class="layui-form-label">办公地址:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_id" type="text" placeholder="请输入办公地址" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">代理备注:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_remarks" type="text" placeholder="请输入代理备注" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">应收账款:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_num" type="text" placeholder="请输入应收账款" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">已收账款:</label>
                                    <div class="layui-input-block">
                                        <input name="sys_cs_money" type="text" placeholder="请输入已收账款" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">生效时间:</label>
                                    <div class="layui-input-block">
                                        <input id="dateRange02" name="sys_create_time" type="text" placeholder="请选择合同生效时间"
                                               class="layui-input date-icon"/>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-md4">
                                    <label class="layui-form-label">到期时间:</label>
                                    <div class="layui-input-block">
                                        <input id="dateRange03" name="sys_over_time" type="text" placeholder="请选择合同到期时间"
                                               class="layui-input date-icon"/>
                                    </div>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
                <div class="layui-inline layui-col-md12" style="text-align: center">
                    <button class="layui-btn" lay-filter="formDemo" lay-submit>&emsp;提交&emsp;</button>
                </div>
            </div>


            <div class="layui-tab-item">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <div class="layui-form layui-form-pane">
                            <div class="layui-form-item">
                                <label class="layui-form-label">合同编号</label>
                                <div class="layui-input-block">
                                    <input id="sys_ct_num" type="text" placeholder="请输入合同编号" class="layui-input" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card-body">
                        <fieldset class="layui-elem-field">
                            <legend>上传合同文件</legend>
                            <div class="layui-field-box">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" id="imageBtn">上 传</button>
                                    <div class="layui-upload-list layui-row layui-col-space10" id="demo2">

                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- js部分 -->
<script type="text/javascript" src="../../assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="../../assets/js/common.js?v=311"></script>

<script>
    layui.use(['layer', 'form', 'upload', 'element', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var upload = layui.upload;
        var element = layui.element;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#dateRange02'
        });
        laydate.render({
            elem: '#dateRange03'
        });
        var str=localStorage.getItem("projects");
        var arr1=str.split(",");
        console.log(arr1)
        for (var i=1;i<arr1.length;i++){
            $("#sys_cs_project").append(' <option value="'+i+'">'+arr1[i]+'</option>')
        }
        form.render('select', 'test1');
        $("#imageBtn").click(function () {
            var num=parseInt($("#sys_ct_num").val());
            if (num>0){
                localStorage.setItem("num", num);

            } else {
                layer.msg("请先填写合同编号",{icon:5})
            }
        })
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
        upload.render({
            elem: '#imageBtn'
            ,url: '/file/fileUploads?sys_cs_num='+parseInt(localStorage.getItem("num"))
            ,multiple: true
            ,before: function(obj){

                /*  obj.preview(function(index, file, result){
                      $('#demo2').append('<div class="layui-col-sm3"><img style="width: 300px;height: 240px" src="'+ result +'" alt="\'+ file.name +\'" class="layui-upload-img"></div>')
                  });*/
            }
            ,done: function(res){
                var image="/upload/"+parseInt(localStorage.getItem("num"))+"/"+res.data;
                if (res.code==0){
                    $('#demo2').append('<div class="layui-col-sm3"><img style="width: 300px;height: 240px" src="'+ image +'"  class="layui-upload-img"></div>')
                    layer.msg("上传成功！",{icon:6})
                }
            }
        });

    });
</script>
</body>

</html>